package com.shop.advertisement.controller;

import com.shop.advertisement.service.IndexRecommendAdService;
import com.shop.pojo.LdbzIndexRecommendAd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/index/recommend/ad/")
public class IndexRecommendAdController {
    private static final Logger logger = LoggerFactory.getLogger(IndexRecommendAdController.class);

    @Autowired
    private IndexRecommendAdService indexRecommendAdService;

    @RequestMapping(value = "/getIndexRecommendAdPage", method = RequestMethod.GET)
    public List<LdbzIndexRecommendAd> getIndexRecommendAdPage(@RequestParam("entity") LdbzIndexRecommendAd entity, @RequestParam("start") int start, @RequestParam("limit") int limit) {
        return indexRecommendAdService.getIndexRecommendAdPage(entity, start, limit);
    }

    @RequestMapping(value = "/countByEntity", method = RequestMethod.GET)
    public long countByEntity(@RequestParam(value = "entity") LdbzIndexRecommendAd entity) {
        logger.debug("countByEntity {}", entity);
        return indexRecommendAdService.countByEntity(entity);
    }

    @RequestMapping(value = "/selectByKey/{id}", method = RequestMethod.GET)
    public LdbzIndexRecommendAd selectByKey(@RequestParam("id") Long id) {
        return indexRecommendAdService.selectByKey(id);
    }

    @RequestMapping(value = "/updateByKey/{entity}", method = RequestMethod.GET)
    public int updateByKey(@RequestParam("entity") LdbzIndexRecommendAd entity){
        return indexRecommendAdService.updateByKey(entity);
    }

    @RequestMapping(value = "/getIndexRecommendAdByRedis", method = RequestMethod.GET)
    public List<LdbzIndexRecommendAd> getIndexRecommendAdByRedis(){
        return indexRecommendAdService.getIndexRecommendAdByRedis();
    }
}
